<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../rurple.css" type="text/css" />

<title>The meaning of synonyms</title>
</head>
<body>
<h2 class="title">The meaning of synonyms</h2>

<p>Remember when I introduced in an earlier lesson the concept of synonym in Python.
(At the time, we were teaching Reeborg a French synonym: avance = move.)  What I call a synonym is normally referred to as a variable.  And the notion of variables, and how they change, can sometimes be confusing to beginners.  Let me try to explain some aspects to you using a little story.</p>

<p>John, Pierre and Antonio are three good friends that share a house.  John is originally from England, Pierre from France and Antonio from Spain.</p>

<p>One day, John was speaking in English to Pierre.  During that conversation, John said the word "once", referring to an event that occurred a single time.  Pierre translated this concept in his mind as "une_fois".</p>
<p>Later that day, John was speaking in Spanish to Antonio.  He mentioned his favourite number: "once" (11).  Here's what it looks like in the Python interpreter:</p>
<pre>
>>> once = 1
>>> une_fois = once

>>> print 'once = ', once, '     une_fois = ', une_fois
once =  1      une_fois =  1

>>> once = 11

>>> print 'once = ', once, '     une_fois = ', une_fois
once =  11      une_fois =  1
</pre>
<p>The various words in human languages are associated with <i>concepts</i> or <i><b>objects</b></i> that are independent of the words used to represent them. So, "une_fois" is associated with the number 1, through its association with the word "once".  However, "once" is just a word, not an <i><b>object</b></i>.  So, when "once" takes on a different value later, the concept represented by "une_fois" is unchanged.</p>
<p>Let us look at a different story.  John makes a groceries shopping list, with two items: "bananas" and "pears".  He then tapes it on the fridge door.  Later that day, Pierre walks by and notices the list too (<i>une liste d'épicerie</i>) which he associates with the word epicerie.  Still later that day, John adds "apples" to the list.  He notices that Antonio had already bought pears and remembers that they also need oranges.  He thus scratches the item "pears" and replaces it by "oranges".  Here's how it looks in Python: </p>
<pre>
>>> groceries = ["bananas", "pears"]
>>> epicerie = groceries
>>> print groceries
['bananas', 'pears']
>>> print epicerie
['bananas', 'pears']

>>> groceries.append("apples")
>>> print groceries
['bananas', 'pears', 'apples']

>>> groceries[1]="oranges"
>>> print groceries
['bananas', 'oranges', 'apples']

>>> print epicerie
['bananas', 'oranges', 'apples']
</pre>
<p>Both John and Pierre are referring to <b>the same object</b> in their own language. When that object changes, it changes for both of them in the same way.</p>
<p>If, however, Pierre had made his own copy of the list, he would have been unaware of the changes made by John on the other list.</p>

<pre>
>>> groceries = ["bananas", "pears"]
>>> epicerie = list(groceries)
>>> groceries.append("apples")
>>> groceries[1] = "oranges"
>>> print groceries
['bananas', 'oranges', 'apples']
>>> print epicerie
['bananas', 'pears']
</pre>


<div class="lessons_nav">
<a href="xx-lesson-1.htm"><img alt="previous" src=
"../../images/previous.png" />Previous lesson</a> - 
<a href="../lessons_toc.htm"><img alt="home" src="../../images/home.png" />
</a> - <a href="xx-lesson+1.htm">Next lesson <img alt="next"
src="../../images/next.png" /></a>
</div>
</body>
</html>
